/* $Id:skill.h $ */
/*
   Copyright (C) 2007 by Jurjen Stellingwerff <jurjen@stwerff.xs4all.nl>
   Part of the Moros Project http://moros.sourceforge.net/

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License version 3.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY.

   See the COPYING file for more details.
*/

#ifndef __SKILL_H
#define __SKILL_H

#include <string>
#include <map>
#include <list>
using namespace std;

#include "special.h"

#define loopSkillSpecials(r,v) loopMap((r)->listSpecials(),v,class special)

class skill {
    class background *background;
    string name;
    string description;
    map<string,class special> specials;
public:
    skill();

    // Field : background
    class background& getBackground() const;
    void setBackground(class background &v);

    // Field : name
    const string getName() const;
    void setName(const string v);

    // Field : description
    const string getDescription() const;
    void setDescription(const string v);

    // Field : specials
    class special& getSpecials(const string v);
    map<string,class special>& listSpecials();
    void setSpecials(class special &v);
    void delSpecials(const string v);
    const bool isSpecials(const string v) const;

    void save(class channel &ch);
    void load(class channel &ch);
    void xml(ofstream &f, int l=0, int r=0);
};

// Repository

#define loopSkills(v) loopMap(skill_repo.listSkill(),v,class skill)

class skillRepository {
    map<string,skill> skills;
public:
    class skill& getSkill(const string v);
    void setSkill(class skill& v);
    map<string,class skill>& listSkill();
    void delSkill(const string v);
    const bool isSkill(const string v) const;
    multimap<string, sigc::signal<void, class skill& > > relations;
    bool load(class channel &ch);
    void save(class channel &ch);
};

extern skillRepository skill_repo;

#endif // __SKILL_H
